class SlidesharesController < ApplicationController
  # GET /slideshares
  # GET /slideshares.xml
  def index
    @slideshares = Slideshare.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @slideshares }
    end
  end

  # GET /slideshares/1
  # GET /slideshares/1.xml
  def show
    @slideshare = Slideshare.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @slideshare }
    end
  end

  # GET /slideshares/new
  # GET /slideshares/new.xml
  def new
    @slideshare = Slideshare.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @slideshare }
    end
  end

  # GET /slideshares/1/edit
  def edit
    @slideshare = Slideshare.find(params[:id])
  end

  # POST /slideshares
  # POST /slideshares.xml
  def create
    @slideshare = Slideshare.new(params[:slideshare])
    
    created = Time.parse(@slideshare.created.to_s)
    unix_created = created.to_i
    
    @slideshare.update_attribute(:created => unix_created)

    respond_to do |format|
      if @slideshare.save
        flash[:notice] = 'Slideshare was successfully created.'
        format.html { redirect_to(@slideshare) }
        format.xml  { render :xml => @slideshare, :status => :created, :location => @slideshare }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @slideshare.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /slideshares/1
  # PUT /slideshares/1.xml
  def update
    @slideshare = Slideshare.find(params[:id])

    respond_to do |format|
      if @slideshare.update_attributes(params[:slideshare])
        flash[:notice] = 'Slideshare was successfully updated.'
        format.html { redirect_to(@slideshare) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @slideshare.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /slideshares/1
  # DELETE /slideshares/1.xml
  def destroy
    @slideshare = Slideshare.find(params[:id])
    @slideshare.destroy

    respond_to do |format|
      format.html { redirect_to(slideshares_url) }
      format.xml  { head :ok }
    end
  end
end
